package com.faradel.pharmapp.dao;

import java.util.List;

import org.faradel.pharmapp.entities.PharmaUser;
import org.faradel.pharmapp.entities.Validation;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

@Repository
public class ValidationDaoImpl extends GenericDAOImpl<Validation, Integer> implements ValidationDAO
{
    @Override
    public PharmaUser verifyUser(String name, String password)
    {
        Criteria criteria = this.sessionFactory.getCurrentSession().createCriteria(Validation.class);
        criteria.add(Restrictions.eq("userName", name));
        criteria.add(Restrictions.eq("userPassword", password));
        criteria.setMaxResults(1);

        @SuppressWarnings("unchecked")
        List<Validation> vlist = criteria.list();

        if (vlist.size() == 0)
            return null;
        else
            return vlist.get(0).getPharmaUser();

    }

    @Override
    public String getUserName(String email)
    {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public String getPassword(String password)
    {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public Validation getSecurityQuestion(String email)
    {
        // TODO Auto-generated method stub
        return null;
    }

}
